import { get, post, put, del } from '@/utils/request';

/**
 * 管理员登录
 * @param data 登录参数
 * @returns 登录结果
 */
export const login = async (data: LOGIN.LoginParams): Promise<LOGIN.LoginResult> => {
  const response = await post('/admin/auth/login', data);

  if (response.code === 200) {
    return response.data;
  } else {
    throw new Error(response.message || '登录失败');
  }
};

/**
 * 管理员登出
 * @returns 登出结果
 */
export const logout = async (): Promise<void> => {
  const response = await post('/admin/auth/logout');

  if (response.code !== 200) {
    throw new Error(response.message || '登出失败');
  }
};
